<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>S110_nRF51822/Source/ble/ble_services/ble_dis.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css" />
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="alias.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="alias.js"></script>

<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>


<script type="text/javascript">
  jQuery(document).ready(function () {
    if(gref){ // Number all _img and _table classes
      gref();
    }
  });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->

<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">nRF51822 BLE SDK
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('ble__dis_8c.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">S110_nRF51822/Source/ble/ble_services/ble_dis.c</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.</span>
<a name="l00002"></a>00002 <span class="comment"> *</span>
<a name="l00003"></a>00003 <span class="comment"> * The information contained herein is property of Nordic Semiconductor ASA.</span>
<a name="l00004"></a>00004 <span class="comment"> * Terms and conditions of usage are described in detail in NORDIC</span>
<a name="l00005"></a>00005 <span class="comment"> * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.</span>
<a name="l00006"></a>00006 <span class="comment"> *</span>
<a name="l00007"></a>00007 <span class="comment"> * Licensees are granted free, non-transferable use of the information. NO</span>
<a name="l00008"></a>00008 <span class="comment"> * WARRANTY of ANY KIND is provided. This heading must NOT be removed from</span>
<a name="l00009"></a>00009 <span class="comment"> * the file.</span>
<a name="l00010"></a>00010 <span class="comment"> *</span>
<a name="l00011"></a>00011 <span class="comment"> * $LastChangedRevision$</span>
<a name="l00012"></a>00012 <span class="comment"> */</span>
<a name="l00013"></a>00013 
<a name="l00014"></a>00014 <span class="preprocessor">#include &quot;<a class="code" href="ble__dis_8h.html">ble_dis.h</a>&quot;</span>
<a name="l00015"></a>00015 
<a name="l00016"></a>00016 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &quot;nrf_error.h&quot;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &quot;<a class="code" href="nrf__assert_8h.html" title="Utilities for verifying program logic.">nrf_assert.h</a>&quot;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &quot;ble_gatts.h&quot;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &quot;<a class="code" href="nordic__common_8h.html" title="Common defines and macros for firmware developed by Nordic Semiconductor.">nordic_common.h</a>&quot;</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include &quot;<a class="code" href="ble__srv__common_8h.html">ble_srv_common.h</a>&quot;</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include &quot;<a class="code" href="ble__sdk__util_8h.html">ble_sdk_util.h</a>&quot;</span>
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 <span class="preprocessor">#define BLE_DIS_SYS_ID_LEN 8                    </span>
<a name="l00027"></a>00027 <span class="preprocessor">#define BLE_DIS_PNP_ID_LEN 7                    </span>
<a name="l00029"></a>00029 <span class="preprocessor">static uint16_t                 service_handle;</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span><span class="keyword">static</span> <a class="code" href="structble__gatts__char__handles__t.html" title="GATT Characteristic Definition Handles.">ble_gatts_char_handles_t</a> manufact_name_handles;
<a name="l00031"></a>00031 <span class="keyword">static</span> <a class="code" href="structble__gatts__char__handles__t.html" title="GATT Characteristic Definition Handles.">ble_gatts_char_handles_t</a> model_num_handles;
<a name="l00032"></a>00032 <span class="keyword">static</span> <a class="code" href="structble__gatts__char__handles__t.html" title="GATT Characteristic Definition Handles.">ble_gatts_char_handles_t</a> serial_num_handles;
<a name="l00033"></a>00033 <span class="keyword">static</span> <a class="code" href="structble__gatts__char__handles__t.html" title="GATT Characteristic Definition Handles.">ble_gatts_char_handles_t</a> hw_rev_handles;
<a name="l00034"></a>00034 <span class="keyword">static</span> <a class="code" href="structble__gatts__char__handles__t.html" title="GATT Characteristic Definition Handles.">ble_gatts_char_handles_t</a> fw_rev_handles;
<a name="l00035"></a>00035 <span class="keyword">static</span> <a class="code" href="structble__gatts__char__handles__t.html" title="GATT Characteristic Definition Handles.">ble_gatts_char_handles_t</a> sw_rev_handles;
<a name="l00036"></a>00036 <span class="keyword">static</span> <a class="code" href="structble__gatts__char__handles__t.html" title="GATT Characteristic Definition Handles.">ble_gatts_char_handles_t</a> sys_id_handles;
<a name="l00037"></a>00037 <span class="keyword">static</span> <a class="code" href="structble__gatts__char__handles__t.html" title="GATT Characteristic Definition Handles.">ble_gatts_char_handles_t</a> reg_cert_data_list_handles;
<a name="l00038"></a>00038 <span class="keyword">static</span> <a class="code" href="structble__gatts__char__handles__t.html" title="GATT Characteristic Definition Handles.">ble_gatts_char_handles_t</a> pnp_id_handles;
<a name="l00039"></a>00039 
<a name="l00040"></a>00040 
<a name="l00041"></a>00041 <span class="keyword">static</span> <span class="keywordtype">void</span> sys_id_encode(uint8_t * p_encoded_buffer, <span class="keyword">const</span> <a class="code" href="structble__dis__sys__id__t.html" title="System ID parameters.">ble_dis_sys_id_t</a> * p_sys_id)
<a name="l00042"></a>00042 {
<a name="l00043"></a>00043     <a class="code" href="nrf__assert_8h.html#a28301f76c53b643912da7c538f74e2c6" title="Assert empty when disabled.">ASSERT</a>(p_sys_id != NULL);
<a name="l00044"></a>00044     <a class="code" href="nrf__assert_8h.html#a28301f76c53b643912da7c538f74e2c6" title="Assert empty when disabled.">ASSERT</a>(p_encoded_buffer != NULL);
<a name="l00045"></a>00045 
<a name="l00046"></a>00046     p_encoded_buffer[0] = (p_sys_id-&gt;<a class="code" href="structble__dis__sys__id__t.html#a4be5ade910055222a8ba6eea783e8783">manufacturer_id</a> &amp; 0x00000000FF);
<a name="l00047"></a>00047     p_encoded_buffer[1] = (p_sys_id-&gt;<a class="code" href="structble__dis__sys__id__t.html#a4be5ade910055222a8ba6eea783e8783">manufacturer_id</a> &amp; 0x000000FF00) &gt;&gt; 8;
<a name="l00048"></a>00048     p_encoded_buffer[2] = (p_sys_id-&gt;<a class="code" href="structble__dis__sys__id__t.html#a4be5ade910055222a8ba6eea783e8783">manufacturer_id</a> &amp; 0x0000FF0000) &gt;&gt; 16;
<a name="l00049"></a>00049     p_encoded_buffer[3] = (p_sys_id-&gt;<a class="code" href="structble__dis__sys__id__t.html#a4be5ade910055222a8ba6eea783e8783">manufacturer_id</a> &amp; 0x00FF000000) &gt;&gt; 24;
<a name="l00050"></a>00050     p_encoded_buffer[4] = (p_sys_id-&gt;<a class="code" href="structble__dis__sys__id__t.html#a4be5ade910055222a8ba6eea783e8783">manufacturer_id</a> &amp; 0xFF00000000) &gt;&gt; 32;
<a name="l00051"></a>00051 
<a name="l00052"></a>00052     p_encoded_buffer[5] = (p_sys_id-&gt;<a class="code" href="structble__dis__sys__id__t.html#af8da1d50631805cfe53b7ed773a6b589">organizationally_unique_id</a> &amp; 0x0000FF);
<a name="l00053"></a>00053     p_encoded_buffer[6] = (p_sys_id-&gt;<a class="code" href="structble__dis__sys__id__t.html#af8da1d50631805cfe53b7ed773a6b589">organizationally_unique_id</a> &amp; 0x00FF00) &gt;&gt; 8;
<a name="l00054"></a>00054     p_encoded_buffer[7] = (p_sys_id-&gt;<a class="code" href="structble__dis__sys__id__t.html#af8da1d50631805cfe53b7ed773a6b589">organizationally_unique_id</a> &amp; 0xFF0000) &gt;&gt; 16;
<a name="l00055"></a>00055 }
<a name="l00056"></a>00056 
<a name="l00057"></a>00057 
<a name="l00058"></a>00058 <span class="keyword">static</span> <span class="keywordtype">void</span> pnp_id_encode(uint8_t * p_encoded_buffer, <span class="keyword">const</span> <a class="code" href="structble__dis__pnp__id__t.html" title="PnP ID parameters.">ble_dis_pnp_id_t</a> * p_pnp_id)
<a name="l00059"></a>00059 {
<a name="l00060"></a>00060     uint8_t len = 0;
<a name="l00061"></a>00061     
<a name="l00062"></a>00062     <a class="code" href="nrf__assert_8h.html#a28301f76c53b643912da7c538f74e2c6" title="Assert empty when disabled.">ASSERT</a>(p_pnp_id != NULL);
<a name="l00063"></a>00063     <a class="code" href="nrf__assert_8h.html#a28301f76c53b643912da7c538f74e2c6" title="Assert empty when disabled.">ASSERT</a>(p_encoded_buffer != NULL);
<a name="l00064"></a>00064 
<a name="l00065"></a>00065     p_encoded_buffer[len++] = p_pnp_id-&gt;<a class="code" href="structble__dis__pnp__id__t.html#a60b6889d45981438b68d1de0d4d4718f">vendor_id_source</a>;
<a name="l00066"></a>00066     
<a name="l00067"></a>00067     len += <a class="code" href="group__ble__sdk__lib__util.html#gab58c28346b89382397aa7a716bf9a178" title="Inline function for encoding a uint16 value.">uint16_encode</a>(p_pnp_id-&gt;<a class="code" href="structble__dis__pnp__id__t.html#abd60aba7846c925f784c3e89e2f54e45">vendor_id</a>, &amp;p_encoded_buffer[len]);
<a name="l00068"></a>00068     len += <a class="code" href="group__ble__sdk__lib__util.html#gab58c28346b89382397aa7a716bf9a178" title="Inline function for encoding a uint16 value.">uint16_encode</a>(p_pnp_id-&gt;<a class="code" href="structble__dis__pnp__id__t.html#a215e5feaef08c77d8e9f17ab421e8a66">product_id</a>, &amp;p_encoded_buffer[len]);
<a name="l00069"></a>00069     len += <a class="code" href="group__ble__sdk__lib__util.html#gab58c28346b89382397aa7a716bf9a178" title="Inline function for encoding a uint16 value.">uint16_encode</a>(p_pnp_id-&gt;<a class="code" href="structble__dis__pnp__id__t.html#add66cd1e2fe782e92652f5f53cef73c8">product_version</a>, &amp;p_encoded_buffer[len]);
<a name="l00070"></a>00070     
<a name="l00071"></a>00071     <a class="code" href="nrf__assert_8h.html#a28301f76c53b643912da7c538f74e2c6" title="Assert empty when disabled.">ASSERT</a>(len == BLE_DIS_PNP_ID_LEN);
<a name="l00072"></a>00072 }
<a name="l00073"></a>00073 
<a name="l00074"></a>00074 
<a name="l00075"></a>00075 <span class="keyword">static</span> uint32_t <a class="code" href="group__ble__sdk__app__pwr__mgmt__main.html#gaefcf3206bdbe52a9eb2e07f58354b783" title="Characteristic add function.">char_add</a>(uint16_t                        uuid,
<a name="l00076"></a>00076                          uint8_t *                       p_char_value,
<a name="l00077"></a>00077                          uint16_t                        char_len,
<a name="l00078"></a>00078                          <span class="keyword">const</span> <a class="code" href="structble__srv__security__mode__t.html" title="Security settings structure.">ble_srv_security_mode_t</a> * dis_attr_md,
<a name="l00079"></a>00079                          <a class="code" href="structble__gatts__char__handles__t.html" title="GATT Characteristic Definition Handles.">ble_gatts_char_handles_t</a> *      p_handles)
<a name="l00080"></a>00080 {
<a name="l00081"></a>00081     <a class="code" href="structble__uuid__t.html" title="Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs.">ble_uuid_t</a>          ble_uuid;
<a name="l00082"></a>00082     <a class="code" href="structble__gatts__char__md__t.html" title="GATT Characteristic Medatadata.">ble_gatts_char_md_t</a> char_md;
<a name="l00083"></a>00083     <a class="code" href="structble__gatts__attr__t.html" title="GATT Attribute.">ble_gatts_attr_t</a>    attr_char_value;
<a name="l00084"></a>00084     <a class="code" href="structble__gatts__attr__md__t.html" title="Attribute metadata.">ble_gatts_attr_md_t</a> attr_md;
<a name="l00085"></a>00085 
<a name="l00086"></a>00086     <a class="code" href="nrf__assert_8h.html#a28301f76c53b643912da7c538f74e2c6" title="Assert empty when disabled.">ASSERT</a>(p_char_value != NULL);
<a name="l00087"></a>00087     <a class="code" href="nrf__assert_8h.html#a28301f76c53b643912da7c538f74e2c6" title="Assert empty when disabled.">ASSERT</a>(char_len &gt; 0);
<a name="l00088"></a>00088     
<a name="l00089"></a>00089     <span class="comment">// The ble_gatts_char_md_t structure uses bit fields. So we reset the memory to zero.</span>
<a name="l00090"></a>00090     memset(&amp;char_md, 0, <span class="keyword">sizeof</span>(char_md));
<a name="l00091"></a>00091 
<a name="l00092"></a>00092     char_md.<a class="code" href="structble__gatts__char__md__t.html#a5d81476b727bf4053879046f72049b48">char_properties</a>.<a class="code" href="structble__gatts__char__properties__t.html#ad99a3f990d972bf0b87f25fd507eb599">read</a> = 1;
<a name="l00093"></a>00093     char_md.<a class="code" href="structble__gatts__char__md__t.html#a48ddd998bdda2b2b93e305ba46137d41">p_char_user_desc</a>     = NULL;
<a name="l00094"></a>00094     char_md.<a class="code" href="structble__gatts__char__md__t.html#ad1fe5fdc8f07028e11054f2288c7fc14">p_char_pf</a>            = NULL;
<a name="l00095"></a>00095     char_md.<a class="code" href="structble__gatts__char__md__t.html#a2bce0c863bf96476ad1629c676042d34">p_user_desc_md</a>       = NULL;
<a name="l00096"></a>00096     char_md.<a class="code" href="structble__gatts__char__md__t.html#a5d654340f27d7c8f113a45beebb50312">p_cccd_md</a>            = NULL;
<a name="l00097"></a>00097     char_md.<a class="code" href="structble__gatts__char__md__t.html#a642bc361c2131bdf054da18ce4e9a3e7">p_sccd_md</a>            = NULL;
<a name="l00098"></a>00098 
<a name="l00099"></a>00099     <a class="code" href="group__ble__types.html#gac4478362651889d2ade8030f53713588" title="Set .type and .uuid fields of ble_uuid_struct to specified uuid value.">BLE_UUID_BLE_ASSIGN</a>(ble_uuid, uuid);
<a name="l00100"></a>00100     
<a name="l00101"></a>00101     memset(&amp;attr_md, 0, <span class="keyword">sizeof</span>(attr_md));
<a name="l00102"></a>00102 
<a name="l00103"></a>00103     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#af0352a482ca2a1305ec5941bc4af0ec2">read_perm</a>  = dis_attr_md-&gt;<a class="code" href="structble__srv__security__mode__t.html#af0352a482ca2a1305ec5941bc4af0ec2">read_perm</a>;
<a name="l00104"></a>00104     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#a6060006e42afe1970aed0a8490f71445">write_perm</a> = dis_attr_md-&gt;<a class="code" href="structble__srv__security__mode__t.html#a6060006e42afe1970aed0a8490f71445">write_perm</a>;
<a name="l00105"></a>00105     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#ac68fa2d9eb5f49771a80414d2c6bb690">rd_defer</a>   = 0;
<a name="l00106"></a>00106     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#ad44d77b2d08d2dde61c9ccbb22fa7432">wr_defer</a>   = 0;
<a name="l00107"></a>00107     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#a248864ad6fe6949aa81d376cdd7d07b4">vlen</a>       = 0;
<a name="l00108"></a>00108     
<a name="l00109"></a>00109     memset(&amp;attr_char_value, 0, <span class="keyword">sizeof</span>(attr_char_value));
<a name="l00110"></a>00110 
<a name="l00111"></a>00111     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a8af1eafb75d1d1e9c4cacf188fad299e">p_uuid</a>       = &amp;ble_uuid;
<a name="l00112"></a>00112     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a573caddb6f66206646fcf38fa7c1a211">p_attr_md</a>    = &amp;attr_md;
<a name="l00113"></a>00113     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a9e68f6d248f0c128406979df16f88255">init_len</a>     = char_len;
<a name="l00114"></a>00114     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a44cd93c5a44c06d426920c36a3971eb1">init_offs</a>    = 0;
<a name="l00115"></a>00115     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a1a6c02276292f164788906e8d5a316e5">max_len</a>      = char_len;
<a name="l00116"></a>00116     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#ac439d398694461e592c0af528994705e">p_init_value</a> = p_char_value;
<a name="l00117"></a>00117 
<a name="l00118"></a>00118     <span class="keywordflow">return</span> <a class="code" href="group___b_l_e___g_a_t_t_s.html#gae4a1d9149f4531d66d06bf289886106d" title="Add a characteristic declaration, a characteristic value declaration and optional characteristic desc...">ble_gatts_characteristic_add</a>(service_handle, &amp;char_md, &amp;attr_char_value, p_handles);
<a name="l00119"></a>00119 }
<a name="l00120"></a>00120 
<a name="l00121"></a>00121 
<a name="l00122"></a><a class="code" href="group__ble__sdk__srv__dis.html#ga472c83dfe2ad977d76b664095a4991cd">00122</a> uint32_t <a class="code" href="group__ble__sdk__srv__dis.html#ga472c83dfe2ad977d76b664095a4991cd" title="Initialize the Device Information Service.">ble_dis_init</a>(<span class="keyword">const</span> <a class="code" href="structble__dis__init__t.html" title="Device Information Service init structure. This contains all possible characteristics needed for init...">ble_dis_init_t</a> * p_dis_init)
<a name="l00123"></a>00123 {
<a name="l00124"></a>00124     uint32_t   err_code;
<a name="l00125"></a>00125     <a class="code" href="structble__uuid__t.html" title="Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs.">ble_uuid_t</a> ble_uuid;
<a name="l00126"></a>00126 
<a name="l00127"></a>00127     <span class="comment">// Add service</span>
<a name="l00128"></a>00128     <a class="code" href="group__ble__types.html#gac4478362651889d2ade8030f53713588" title="Set .type and .uuid fields of ble_uuid_struct to specified uuid value.">BLE_UUID_BLE_ASSIGN</a>(ble_uuid, <a class="code" href="group___u_u_i_d___s_e_r_v_i_c_e_s.html#gab8eac87431b53cdfaeccd6d3a15ed5ac">BLE_UUID_DEVICE_INFORMATION_SERVICE</a>);
<a name="l00129"></a>00129 
<a name="l00130"></a>00130     err_code = <a class="code" href="group___b_l_e___g_a_t_t_s.html#ga5e8270fe6dfa01e446be17b48fe81e2a" title="Add a service declaration to the local server database.">ble_gatts_service_add</a>(<a class="code" href="group___b_l_e___g_a_t_t_s___s_v_c___t_y_p_e_s.html#ga713ed30865fa70c89587ba981f114a91">BLE_GATTS_SVC_TYPE_PRIMARY</a>, &amp;ble_uuid, &amp;service_handle);
<a name="l00131"></a>00131     <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00132"></a>00132     {
<a name="l00133"></a>00133         <span class="keywordflow">return</span> err_code;
<a name="l00134"></a>00134     }
<a name="l00135"></a>00135 
<a name="l00136"></a>00136     <span class="comment">// Add characteristics</span>
<a name="l00137"></a>00137     <span class="keywordflow">if</span> (p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#a02a650cde3f65fc67f65b5fb4cd33425">manufact_name_str</a>.<a class="code" href="structble__srv__utf8__str__t.html#a1892eba2086d12ac2b09005aeb09ea3b">length</a> &gt; 0)
<a name="l00138"></a>00138     {
<a name="l00139"></a>00139         err_code = <a class="code" href="group__ble__sdk__app__pwr__mgmt__main.html#gaefcf3206bdbe52a9eb2e07f58354b783" title="Characteristic add function.">char_add</a>(<a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#ga8f8578321e635bf151c277cfc1f4a152">BLE_UUID_MANUFACTURER_NAME_STRING_CHAR</a>,
<a name="l00140"></a>00140                             p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#a02a650cde3f65fc67f65b5fb4cd33425">manufact_name_str</a>.<a class="code" href="structble__srv__utf8__str__t.html#a8625c86b8c951e7f96b1e7fa70e7cc41">p_str</a>, 
<a name="l00141"></a>00141                             p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#a02a650cde3f65fc67f65b5fb4cd33425">manufact_name_str</a>.<a class="code" href="structble__srv__utf8__str__t.html#a1892eba2086d12ac2b09005aeb09ea3b">length</a>,
<a name="l00142"></a>00142                             &amp;p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#aa3268ab4659686cb4202651e071af265">dis_attr_md</a>,
<a name="l00143"></a>00143                             &amp;manufact_name_handles);
<a name="l00144"></a>00144         <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00145"></a>00145         {
<a name="l00146"></a>00146             <span class="keywordflow">return</span> err_code;
<a name="l00147"></a>00147         }
<a name="l00148"></a>00148     }
<a name="l00149"></a>00149     <span class="keywordflow">if</span> (p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#a6a7f9f8488819d498650e61d6f3e7943">model_num_str</a>.<a class="code" href="structble__srv__utf8__str__t.html#a1892eba2086d12ac2b09005aeb09ea3b">length</a> &gt; 0)
<a name="l00150"></a>00150     {
<a name="l00151"></a>00151         err_code = <a class="code" href="group__ble__sdk__app__pwr__mgmt__main.html#gaefcf3206bdbe52a9eb2e07f58354b783" title="Characteristic add function.">char_add</a>(<a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#ga532c5062edf52c03c15eb326b9e0a197">BLE_UUID_MODEL_NUMBER_STRING_CHAR</a>,
<a name="l00152"></a>00152                             p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#a6a7f9f8488819d498650e61d6f3e7943">model_num_str</a>.<a class="code" href="structble__srv__utf8__str__t.html#a8625c86b8c951e7f96b1e7fa70e7cc41">p_str</a>, 
<a name="l00153"></a>00153                             p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#a6a7f9f8488819d498650e61d6f3e7943">model_num_str</a>.<a class="code" href="structble__srv__utf8__str__t.html#a1892eba2086d12ac2b09005aeb09ea3b">length</a>,
<a name="l00154"></a>00154                             &amp;p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#aa3268ab4659686cb4202651e071af265">dis_attr_md</a>,
<a name="l00155"></a>00155                             &amp;model_num_handles);
<a name="l00156"></a>00156         <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00157"></a>00157         {
<a name="l00158"></a>00158             <span class="keywordflow">return</span> err_code;
<a name="l00159"></a>00159         }
<a name="l00160"></a>00160     }
<a name="l00161"></a>00161     <span class="keywordflow">if</span> (p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#a0c16fc82f6cadca2324ea7e47a9012eb">serial_num_str</a>.<a class="code" href="structble__srv__utf8__str__t.html#a1892eba2086d12ac2b09005aeb09ea3b">length</a> &gt; 0)
<a name="l00162"></a>00162     {
<a name="l00163"></a>00163         err_code = <a class="code" href="group__ble__sdk__app__pwr__mgmt__main.html#gaefcf3206bdbe52a9eb2e07f58354b783" title="Characteristic add function.">char_add</a>(<a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#ga417d8b27e6bbbfe6016393a4808dae08">BLE_UUID_SERIAL_NUMBER_STRING_CHAR</a>,
<a name="l00164"></a>00164                             p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#a0c16fc82f6cadca2324ea7e47a9012eb">serial_num_str</a>.<a class="code" href="structble__srv__utf8__str__t.html#a8625c86b8c951e7f96b1e7fa70e7cc41">p_str</a>, 
<a name="l00165"></a>00165                             p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#a0c16fc82f6cadca2324ea7e47a9012eb">serial_num_str</a>.<a class="code" href="structble__srv__utf8__str__t.html#a1892eba2086d12ac2b09005aeb09ea3b">length</a>,
<a name="l00166"></a>00166                             &amp;p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#aa3268ab4659686cb4202651e071af265">dis_attr_md</a>,
<a name="l00167"></a>00167                             &amp;serial_num_handles);
<a name="l00168"></a>00168         <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00169"></a>00169         {
<a name="l00170"></a>00170             <span class="keywordflow">return</span> err_code;
<a name="l00171"></a>00171         }
<a name="l00172"></a>00172     }
<a name="l00173"></a>00173     <span class="keywordflow">if</span> (p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#af569ccba2c37863c84d7c6bc59fafea1">hw_rev_str</a>.<a class="code" href="structble__srv__utf8__str__t.html#a1892eba2086d12ac2b09005aeb09ea3b">length</a> &gt; 0)
<a name="l00174"></a>00174     {
<a name="l00175"></a>00175         err_code = <a class="code" href="group__ble__sdk__app__pwr__mgmt__main.html#gaefcf3206bdbe52a9eb2e07f58354b783" title="Characteristic add function.">char_add</a>(<a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#gae29e769199c4324a4f0123d37b115c0f">BLE_UUID_HARDWARE_REVISION_STRING_CHAR</a>,
<a name="l00176"></a>00176                             p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#af569ccba2c37863c84d7c6bc59fafea1">hw_rev_str</a>.<a class="code" href="structble__srv__utf8__str__t.html#a8625c86b8c951e7f96b1e7fa70e7cc41">p_str</a>, 
<a name="l00177"></a>00177                             p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#af569ccba2c37863c84d7c6bc59fafea1">hw_rev_str</a>.<a class="code" href="structble__srv__utf8__str__t.html#a1892eba2086d12ac2b09005aeb09ea3b">length</a>, 
<a name="l00178"></a>00178                             &amp;p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#aa3268ab4659686cb4202651e071af265">dis_attr_md</a>,
<a name="l00179"></a>00179                             &amp;hw_rev_handles);
<a name="l00180"></a>00180         <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00181"></a>00181         {
<a name="l00182"></a>00182             <span class="keywordflow">return</span> err_code;
<a name="l00183"></a>00183         }
<a name="l00184"></a>00184     }
<a name="l00185"></a>00185     <span class="keywordflow">if</span> (p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#a7dc4439cfb3bb894944eb37a7b2ddc48">fw_rev_str</a>.<a class="code" href="structble__srv__utf8__str__t.html#a1892eba2086d12ac2b09005aeb09ea3b">length</a> &gt; 0)
<a name="l00186"></a>00186     {
<a name="l00187"></a>00187         err_code = <a class="code" href="group__ble__sdk__app__pwr__mgmt__main.html#gaefcf3206bdbe52a9eb2e07f58354b783" title="Characteristic add function.">char_add</a>(<a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#ga7ff0e67deccd8dda48960197b0154a31">BLE_UUID_FIRMWARE_REVISION_STRING_CHAR</a>,
<a name="l00188"></a>00188                             p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#a7dc4439cfb3bb894944eb37a7b2ddc48">fw_rev_str</a>.<a class="code" href="structble__srv__utf8__str__t.html#a8625c86b8c951e7f96b1e7fa70e7cc41">p_str</a>, 
<a name="l00189"></a>00189                             p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#a7dc4439cfb3bb894944eb37a7b2ddc48">fw_rev_str</a>.<a class="code" href="structble__srv__utf8__str__t.html#a1892eba2086d12ac2b09005aeb09ea3b">length</a>, 
<a name="l00190"></a>00190                             &amp;p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#aa3268ab4659686cb4202651e071af265">dis_attr_md</a>,
<a name="l00191"></a>00191                             &amp;fw_rev_handles);
<a name="l00192"></a>00192         <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00193"></a>00193         {
<a name="l00194"></a>00194             <span class="keywordflow">return</span> err_code;
<a name="l00195"></a>00195         }
<a name="l00196"></a>00196     }
<a name="l00197"></a>00197     <span class="keywordflow">if</span> (p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#a272a54a577fefcb2b60324520ee133f2">sw_rev_str</a>.<a class="code" href="structble__srv__utf8__str__t.html#a1892eba2086d12ac2b09005aeb09ea3b">length</a> &gt; 0)
<a name="l00198"></a>00198     {
<a name="l00199"></a>00199         err_code = <a class="code" href="group__ble__sdk__app__pwr__mgmt__main.html#gaefcf3206bdbe52a9eb2e07f58354b783" title="Characteristic add function.">char_add</a>(<a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#gaae2190189c63a43632f3b060759d7d44">BLE_UUID_SOFTWARE_REVISION_STRING_CHAR</a>,
<a name="l00200"></a>00200                             p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#a272a54a577fefcb2b60324520ee133f2">sw_rev_str</a>.<a class="code" href="structble__srv__utf8__str__t.html#a8625c86b8c951e7f96b1e7fa70e7cc41">p_str</a>, 
<a name="l00201"></a>00201                             p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#a272a54a577fefcb2b60324520ee133f2">sw_rev_str</a>.<a class="code" href="structble__srv__utf8__str__t.html#a1892eba2086d12ac2b09005aeb09ea3b">length</a>, 
<a name="l00202"></a>00202                             &amp;p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#aa3268ab4659686cb4202651e071af265">dis_attr_md</a>,
<a name="l00203"></a>00203                             &amp;sw_rev_handles);
<a name="l00204"></a>00204         <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00205"></a>00205         {
<a name="l00206"></a>00206             <span class="keywordflow">return</span> err_code;
<a name="l00207"></a>00207         }
<a name="l00208"></a>00208     }
<a name="l00209"></a>00209     <span class="keywordflow">if</span> (p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#a853998bc0e7852a4eb9ac0fa812b95fc">p_sys_id</a> != NULL)
<a name="l00210"></a>00210     {
<a name="l00211"></a>00211         uint8_t encoded_sys_id[BLE_DIS_SYS_ID_LEN];
<a name="l00212"></a>00212         
<a name="l00213"></a>00213         sys_id_encode(encoded_sys_id, p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#a853998bc0e7852a4eb9ac0fa812b95fc">p_sys_id</a>);
<a name="l00214"></a>00214         err_code = <a class="code" href="group__ble__sdk__app__pwr__mgmt__main.html#gaefcf3206bdbe52a9eb2e07f58354b783" title="Characteristic add function.">char_add</a>(<a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#gab64d330c6022106955c0b825649d9485">BLE_UUID_SYSTEM_ID_CHAR</a>,
<a name="l00215"></a>00215                             encoded_sys_id, 
<a name="l00216"></a>00216                             BLE_DIS_SYS_ID_LEN, 
<a name="l00217"></a>00217                             &amp;p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#aa3268ab4659686cb4202651e071af265">dis_attr_md</a>,
<a name="l00218"></a>00218                             &amp;sys_id_handles);
<a name="l00219"></a>00219         <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00220"></a>00220         {
<a name="l00221"></a>00221             <span class="keywordflow">return</span> err_code;
<a name="l00222"></a>00222         }
<a name="l00223"></a>00223     }
<a name="l00224"></a>00224     <span class="keywordflow">if</span> (p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#a69ba763dc9d6010e87359a1002c48551">p_reg_cert_data_list</a> != NULL)
<a name="l00225"></a>00225     {
<a name="l00226"></a>00226         err_code = <a class="code" href="group__ble__sdk__app__pwr__mgmt__main.html#gaefcf3206bdbe52a9eb2e07f58354b783" title="Characteristic add function.">char_add</a>(<a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#ga033523799a247bd7c0806569e38c6863">BLE_UUID_IEEE_REGULATORY_CERTIFICATION_DATA_LIST_CHAR</a>,
<a name="l00227"></a>00227                             p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#a69ba763dc9d6010e87359a1002c48551">p_reg_cert_data_list</a>-&gt;<a class="code" href="structble__dis__reg__cert__data__list__t.html#a831226e914e2d07f1224fe2348f62e5c">p_list</a>,
<a name="l00228"></a>00228                             p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#a69ba763dc9d6010e87359a1002c48551">p_reg_cert_data_list</a>-&gt;<a class="code" href="structble__dis__reg__cert__data__list__t.html#acd6a7a23d3b336183fb40ae740cc1527">list_len</a>,
<a name="l00229"></a>00229                             &amp;p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#aa3268ab4659686cb4202651e071af265">dis_attr_md</a>,
<a name="l00230"></a>00230                             &amp;reg_cert_data_list_handles);
<a name="l00231"></a>00231         <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00232"></a>00232         {
<a name="l00233"></a>00233             <span class="keywordflow">return</span> err_code;
<a name="l00234"></a>00234         }
<a name="l00235"></a>00235     }
<a name="l00236"></a>00236     <span class="keywordflow">if</span> (p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#a5b5d4c8fc2a17cfa2e94e1c0b55f3672">p_pnp_id</a> != NULL)
<a name="l00237"></a>00237     {
<a name="l00238"></a>00238         uint8_t encoded_pnp_id[BLE_DIS_PNP_ID_LEN];
<a name="l00239"></a>00239         
<a name="l00240"></a>00240         pnp_id_encode(encoded_pnp_id, p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#a5b5d4c8fc2a17cfa2e94e1c0b55f3672">p_pnp_id</a>);
<a name="l00241"></a>00241         err_code = <a class="code" href="group__ble__sdk__app__pwr__mgmt__main.html#gaefcf3206bdbe52a9eb2e07f58354b783" title="Characteristic add function.">char_add</a>(<a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#gaf60a9da39d7c0ee6b8d0340e1135a1f3">BLE_UUID_PNP_ID_CHAR</a>,
<a name="l00242"></a>00242                             encoded_pnp_id, 
<a name="l00243"></a>00243                             BLE_DIS_PNP_ID_LEN, 
<a name="l00244"></a>00244                             &amp;p_dis_init-&gt;<a class="code" href="structble__dis__init__t.html#aa3268ab4659686cb4202651e071af265">dis_attr_md</a>,
<a name="l00245"></a>00245                             &amp;pnp_id_handles);
<a name="l00246"></a>00246         <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00247"></a>00247         {
<a name="l00248"></a>00248             <span class="keywordflow">return</span> err_code;
<a name="l00249"></a>00249         }
<a name="l00250"></a>00250     }
<a name="l00251"></a>00251     
<a name="l00252"></a>00252     <span class="keywordflow">return</span> <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>;
<a name="l00253"></a>00253 }
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><b>ble_dis.c</b>      </li>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>


    <li class="footer">
      Copyright &copy 2006-2011 <a href="http://www.nordicsemi.no" style="text-decoration:none">Nordic Semiconductor</a>.
      All Rights Reserved.
      <a href="disclaimer.html">Disclaimer</a>
    </li>
   </ul>
 </div>


</body>
</html>
